<template>
  <div>
    <el-card>
      <el-table ref="tableName" :data="applyVipList" height="500px" style="margin: 10px 0 10px" border :header-cell-style="{ background: '#FAFAFA' }">
        <el-table-column align="center" type="index"></el-table-column>
        <el-table-column align="center" label="用户账号" prop="username" width="120px" show-overflow-tooltip></el-table-column>
        <el-table-column align="center" label="用户姓名" prop="realname" width="120px" show-overflow-tooltip></el-table-column>
        <el-table-column align="center" label="手机号码" prop="phone" width="120px" show-overflow-tooltip></el-table-column>
        <el-table-column align="center" label="邮箱" prop="email" show-overflow-tooltip></el-table-column>
        <el-table-column align="center" label="工作单位" prop="workUnit" width="140px" show-overflow-tooltip></el-table-column>
        <el-table-column align="center" label="院系/部门" prop="departs" width="140px" show-overflow-tooltip></el-table-column>
        <el-table-column align="center" label="职务" prop="post" width="140px" show-overflow-tooltip></el-table-column>
        <el-table-column align="center" label="访问量" prop="count" width="100px" show-overflow-tooltip></el-table-column>
        <el-table-column align="center" label="注册时间" prop="createTime" show-overflow-tooltip></el-table-column>
        <el-table-column align="center" label="申请时间" prop="applyTime" show-overflow-tooltip></el-table-column>
        <el-table-column align="center" label="操作" fixed="right" width="200px">
          <template slot-scope="scope">
            <el-popconfirm title="确定同意吗？" @confirm="passData(scope.row)">
              <el-button slot="reference" type="text" style="color:green" size="mini">同意</el-button>
            </el-popconfirm>
            <el-divider direction="vertical"></el-divider>
            <el-popconfirm title="确定拒绝吗？" @confirm="rejectData(scope.row)">
              <el-button slot="reference" type="text" style="color:red" size="mini">拒绝</el-button>
            </el-popconfirm>
          </template>
        </el-table-column>
      </el-table>
      <!-- 分页区 -->
      <!-- <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="queryInfo.pagenum" :page-sizes="[10, 20]" :page-size="queryInfo.pagesize" layout="total, sizes, prev, pager, next, jumper" :total="total"> </el-pagination> -->
    </el-card>
  </div>
</template>

<script>
import { Message } from 'element-ui'
export default {
  data() {
    return {
      applyVipList: [],
      queryInfo: {
        //当前的页数
        pageNum: 1,
        //当前每页显示多少条数据
        pageSize: 10
      },
      total: 0
    }
  },
  mounted() {
    this.loadData()
  },
  methods: {
    loadData() {
      this.axios({
        baseURL: 'http://59.172.104.174:30669',
        url: `/admin/adminCheckVip`,
        method: 'POST'
      }).then(res => {
        this.applyVipList = res.data.result.list
      })
    },
    passData(row) {
      this.axios({
        baseURL: 'http://59.172.104.174:30669',
        url: `/admin/adminPassVip?userId=${row.id}&&pass=true`,
        method: 'POST'
      }).then(res => {
        if (res.data.code == 200) {
          this.loadData()
          Message({
            message: '操作成功',
            type: 'success',
            center: true,
            customClass: 'mzindex'
          })
        } else {
          Message({
            message: '操作失败',
            type: 'error',
            center: true,
            customClass: 'mzindex'
          })
        }
      })
    },
    rejectData(row) {
      this.axios({
        baseURL: 'http://59.172.104.174:30669',
        url: `/admin/adminPassVip?userId=${row.id}&&pass=false`,
        method: 'POST'
      }).then(res => {
        if (res.data.code == 200) {
          this.loadData()
          Message({
            message: '操作成功',
            type: 'success',
            center: true,
            customClass: 'mzindex'
          })
        } else {
          Message({
            message: '操作失败',
            type: 'error',
            center: true,
            customClass: 'mzindex'
          })
        }
      })
    },
    handleSizeChange() {},
    handleCurrentChange() {}
  }
}
</script>

<style></style>
